Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the Makefile more robust, readable and safe #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ptosi
Copy link

@ptosi ptosi commented Apr 10, 2018

The Makefile has been modified to make use of the features of Make
with the general objective of increasing robustness, readability
and safety of the code through a reduction in redundancy and an
increase in automatic work.

The dependencies have been grouped to express clearly that they can
be of one of 2 kinds: hardware-dependant assembly or higher-level
source. Thanks to this, the dependency tree that the Makefile defines
becomes clearer (main depends on source and source depends on asm).
The use of Pattern Rules (Static or not) and variables (Automatic
or not) make the code more readable and robuster by expressing
redundancy in a non-literal way.

Extending the tool to support a new hardware (i.e. adding to the
project a new .S file and some code in asm-opt) now only requires to
add the name of the extension in ${ASM} and this will cascade down
the tree. This is more robust than the previous solution which required
multiple modifications. This new approach fixes a mistake on line 13
where the rule asm-opt.o : aarch64-asm.h was NOT defined while
being required from line 335 in asm-opt.c!

all and clean are declared as phony variables to increase robustness.

'-O2' was removed from the call to the compiler as it is a compiler
flag and we believe that it should be in ${CFLAGS}.

Thanks to the previous change, the rm -f *.o command in the clean
rule was made safer so it is now unable to delete .o files that it
couldn't have created.

A ${NAME} variable is used to further reduce redundancy.

The Makefile has been modified to make use of the features of Make
with the general objective of increasing robustness, readability
and safety of the code through a reduction in redundancy and an
increase in automatic work.

The dependencies have been grouped to express clearly that they can
be of one of 2 kinds: hardware-dependant assembly or higher-level
source. Thanks to this, the dependency tree that the Makefile defines
becomes clearer (main depends on source and source depends on asm).
The use of Pattern Rules (Static or not) and variables (Automatic
or not) make the code more readable and robuster by expressing
redundancy in a non-literal way.

Extending the tool to support a new hardware (i.e. adding to the
project a new .S file and some code in asm-opt) now only requires to
add the name of the extension in ${ASM} and this will cascade down
the tree. This is more robust than the previous solution which required
multiple modifications. This new approach fixes a mistake on line 13
where the rule 'asm-opt.o : aarch64-asm.h' was NOT defined while
being required from line 335 in asm-opt.c!

all and clean are declared as phony variables to increase robustness.

'-O2' was removed from the call to the compiler as it is a compiler
flag and we believe that it should be in ${CFLAGS}.

Thanks to the previous change, the `rm -f *.o` command in the clean
rule was made safer so it is now unable to delete .o files that it
couldn't have created.

A ${NAME} variable is used to further reduce redundancy.
@ptosi ptosi force-pushed the hotfix/makefile-update branch from 3bc1c7e to c77a222 Compare June 15, 2018 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants